package com.shenxuchen.crm.mapper;

import com.shenxuchen.crm.pojo.Dept;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface DeptMapper {
    @Select("select * from tbl_dept where id=#{id}")
    Dept getById(String id);

    @Select("select * from tbl_dept")
    List<Dept> getAllDept();

    // 0: false, 1: true
    @Select("select count(*) from tbl_dept where no=#{no}")
    Boolean checkNo(String no);

    @Insert("insert into tbl_dept values(" +
            "#{id}," +
            "#{no}," +
            "#{name}," +
            "#{manager}," +
            "#{description}," +
            "#{phone}" +
            ")")
    void save(Dept dept);

    @Update("update tbl_dept set " +
            "no=#{no}," +
            "name=#{name}," +
            "manager=#{manager}," +
            "description=#{description}," +
            "phone=#{phone} " +
            "where id=#{id}")
    void edit(Dept dept);

    void delete(String[] ids);

    List getHasUser(String[] ids);
}
